from django.shortcuts import render
from django.views.generic import ListView, UpdateView, DeleteView, CreateView, DetailView
from .models import Chanpin
from .forms import ChanpinForm
# Create your views here.
class 产品列表(ListView):
    model = Chanpin
    template_name = 'chanpin_list.html'
    context_object_name = 'chanpins'
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        return context
    def get_queryset(self):
        return Chanpin.objects.all()

class ChanpinCreateView(CreateView):
    model = Chanpin
    form_class = ChanpinForm
    template_name = 'chanpin_add.html'
    success_url = 'product_list'


# class ChanpinDetailView(DetailView):
#     model = Chanpin
#     template_name = 'chanpin_detail.html'
#     context_object_name = 'chanpin'
#
#     def get_context_data(self, **kwargs):
#         context = super().get_context_data(**kwargs)
#         return context
#
#
